import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace BookingCheckinDetailApi {
  /** 签到明细信息 */
  export interface BookingCheckinDetail {
    id: number; // 签到明细ID
    checkinMasterId?: number; // 签到主表ID
    detailCode?: string; // 明细编码
    sequenceNo?: number; // 明细序号
    customerId?: number; // 客户ID
    customerName?: string; // 客户姓名
    customerPhone: string; // 客户电话
    customerGender: string; // 性别
    customerAge: number; // 年龄
    groupMemberId: number; // 团体成员ID
    groupMemberSequence: number; // 团体成员序号
    isGroupLeader: boolean; // 是否团体负责人
    checkinStatus?: string; // 个人签到状态
    expectedArrivalTime: string | Dayjs; // 个人预计到店时间
    actualArrivalTime: string | Dayjs; // 个人实际到店时间
    checkinTime: string | Dayjs; // 个人签到时间
    checkinMethod: string; // 签到方式
    checkinUserId: number; // 签到操作人ID
    checkinNotes: string; // 个人签到备注
    isLate: boolean; // 是否迟到
    lateMinutes: number; // 迟到分钟数
    lateReason: string; // 迟到原因
    convertedOrderId: number; // 转换后的消费订单ID
    conversionTime: string | Dayjs; // 转换时间
    conversionUserId: number; // 转换操作人ID
    specialRequirements: string; // 特殊需求
    healthNotes: string; // 健康备注
  }
}

/** 查询签到明细分页 */
export function getBookingCheckinDetailPage(params: PageParam) {
  return requestClient.get<PageResult<BookingCheckinDetailApi.BookingCheckinDetail>>('/spa/booking-checkin-detail/page', { params });
}

/** 查询签到明细详情 */
export function getBookingCheckinDetail(id: number) {
  return requestClient.get<BookingCheckinDetailApi.BookingCheckinDetail>(`/spa/booking-checkin-detail/get?id=${id}`);
}

/** 新增签到明细 */
export function createBookingCheckinDetail(data: BookingCheckinDetailApi.BookingCheckinDetail) {
  return requestClient.post('/spa/booking-checkin-detail/create', data);
}

/** 修改签到明细 */
export function updateBookingCheckinDetail(data: BookingCheckinDetailApi.BookingCheckinDetail) {
  return requestClient.put('/spa/booking-checkin-detail/update', data);
}

/** 删除签到明细 */
export function deleteBookingCheckinDetail(id: number) {
  return requestClient.delete(`/spa/booking-checkin-detail/delete?id=${id}`);
}


/** 导出签到明细 */
export function exportBookingCheckinDetail(params: any) {
  return requestClient.download('/spa/booking-checkin-detail/export-excel', { params });
}

